﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Serialization;

namespace Labthink.PCSoft.UniversalHost4.Model
{

    [DebuggerDisplay("{DataNo,nq},{Name,nq},Value={Value,nq}")] //nq:No Quote 去掉最终显示的引号
    public class Param
    {
        [XmlAttribute]
        public int DataNo { get; set; }

        [XmlAttribute]
        public string Name { get; set; }

        [XmlAttribute]
        public double Min { get; set; }

        [XmlAttribute]
        public double Max { get; set; }

        [XmlAttribute]
        public int MaxLength { get; set; }

        [XmlText]
        public string Value { get; set; }

        [XmlIgnore]
        public string LanguageId { get; set; }

        [XmlIgnore]
        public string Text { get; set; }

        [XmlIgnore]
        public string Unit { get; set; }

        [XmlIgnore]
        public int Precision { get; set; }

        [XmlIgnore]
        public DataType DataType { get; set; }

        [XmlIgnore]
        public string ColumnName { get; set; }

        public object Clone()
        {
            return new Param
            {
                DataNo = DataNo,
                DataType = DataType,
                Value = string.Copy(Value),
                Min = Min,
                Max = Max,
                MaxLength = MaxLength,
                Name = string.Copy(Name),
                Text = string.Copy(Text),
                Unit = string.Copy(Unit),
                ColumnName = string.Copy(ColumnName),
                LanguageId = string.Copy(LanguageId),
                Precision =  Precision,
            };
        }
    }

    [XmlRoot("DefaultParam")]
    public class DefaultParam
    {
        [XmlIgnore]
        public string Filename { get; set; }

        [XmlAttribute]
        public int TestType { get; set; }

        [XmlAttribute]
        public string Name { get; set; }

        [XmlAttribute]
        public DateTime LastUsed { get; set; }

        [XmlAttribute]
        public bool IsDefault { get; set; }

        [XmlArray]
        public List<Param> Params { get; set; }
    }
}
